#! /bin/sh
ftincludes=/usr/include/freetype2
ftlib=/usr/lib/libfreetype.so
cat <<EOT >ft.tmp
|
| HelFORTH interface to libfreetype
|
context FreeType
{~ FreeType
lazylink libfreetype.so
EOT
for a in `(cd $ftincludes/freetype ; ls *.h )` ; do
  ./fugen freetype/$a --addcode='#include <ft2build.h>' \
  -- -I$ftincludes >>ft.tmp
done
echo lazy off >>ft.tmp
echo ~} >>ft.tmp
bong $ftlib <ft.tmp | perl >freetype.interface -e '
#
# cleanups
#
  my $last = "";
  while (<>) {
  	my ($w, $x, $y);
  	while (/^\|\n/) {
  		$w = $_;
  		$x = <>;
  		$y = <>;
  		$_ = <>;
  		if (/^((\|)|(lazy))/) {
  			$w = $x = $y = "";
  		}
  	}
	/^lazy/ and $last = "";
  	print $last, $w, $x, $y;
  	if (/^lazy/) {
  		$last = "\n\n$_";
  	} else {
  		print $_;
  		$last = "";
  	}
  }
  print $last; # lazy off
'
rm -f ft.tmp
